package com.huangwei.service.impl;

import com.google.gson.Gson;
import com.huangwei.dao.OrdersDao;
import com.huangwei.model.Orders;
import com.huangwei.service.OrdersService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class OrdersServiceImpl implements OrdersService {
    @Resource
    private OrdersDao ordersDao;

    @Override
    public int addOrder(Orders orders) {
        try {
            return ordersDao.add(orders);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return -1;
    }

    @Override
    public int deleteOrder(int id) {
        try {
            return ordersDao.delete(id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return -1;
    }

    @Override
    public List<Orders> getOrdersByUserId(int userID) {
        try {
            return ordersDao.queryByUser(userID);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
